package com.eos.control.action.activity;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.eos.business.service.SysActivityBusinessService;
import com.eos.common.tool.ConstantTool;
import com.eos.control.action.base.AbstractBaseAction;
import com.eos.orm.mybatis.model.ActivtyMappSales;
import com.eos.orm.mybatis.model.SalesModel;
import com.eos.orm.mybatis.model.SysCombo;
import com.hf.utils.PaginationBean;

public class ModelComboListAction extends AbstractBaseAction {
	private static final long serialVersionUID = 6365217794646695694L;
	private String mappId;
	private String comboId;
	private String salesId;
	private String dealFlag;
	private Integer pageNum;
	private Integer numPerPage;
	private List<SysCombo> comboList;
	private List<SalesModel> salesList;
	private List<ActivtyMappSales> activtySalesList;
	private Integer totalCount;
	
	public String getMappId() {
		return mappId;
	}

	public void setMappId(String mappId) {
		this.mappId = mappId;
	}

	public String getComboId() {
		return comboId;
	}

	public String getSalesId() {
		return salesId;
	}

	public void setSalesId(String salesId) {
		this.salesId = salesId;
	}

	public void setComboId(String comboId) {
		this.comboId = comboId;
	}

	public String getDealFlag() {
		return dealFlag;
	}

	public void setDealFlag(String dealFlag) {
		this.dealFlag = dealFlag;
	}

	public List<SysCombo> getComboList() {
		return comboList;
	}

	public List<SalesModel> getSalesList() {
		return salesList;
	}

	public Integer getTotalCount() {
		return totalCount;
	}

	public List<ActivtyMappSales> getActivtySalesList() {
		return activtySalesList;
	}

	public Integer getPageNum() {
		return pageNum;
	}

	public void setPageNum(Integer pageNum) {
		this.pageNum = pageNum;
	}

	public Integer getNumPerPage() {
		return numPerPage;
	}

	public void setNumPerPage(Integer numPerPage) {
		this.numPerPage = numPerPage;
	}

	@SuppressWarnings("unchecked")
	@Override
	public String execute()  {
		try{
			SysActivityBusinessService sabs = new SysActivityBusinessService();
			SysCombo combo = new SysCombo();
			combo.setDealFlag(ConstantTool.DEAL_FALG_OK);
			combo.setStatus(ConstantTool.STATUS_OK);
			comboList = sabs.getAllSysComboExample(combo);
			
			SalesModel sm = new SalesModel();
			sm.setDealFlag(ConstantTool.DEAL_FALG_OK);
			sm.setStatus(ConstantTool.STATUS_OK);
			salesList = sabs.getAllSalesModelExample(sm);
			
			if(pageNum == null || pageNum.intValue() == 0) pageNum =1;
			if(numPerPage == null || numPerPage.intValue() == 0) numPerPage = PAGE_SIZE;
			Map<String, String> map = new HashMap<String, String>();
			map.put("cur_page", pageNum+"");
			map.put("page_size", numPerPage+"");
			map.put("sales_id", salesId);
			map.put("deal_flag", dealFlag);
			map.put("combo_id", comboId);
			map.put("table_name", "activty_mapp_sales");
			PaginationBean pageBean = sabs.getActivitySalesList(map);
			totalCount = null != pageBean ? pageBean.getMaxcount() : 0;
			activtySalesList = null != pageBean ? (List<ActivtyMappSales>) pageBean.getResultList() : null;
		}catch (Exception e) {
			e.printStackTrace();
		}
		return SUCCESS;
	}
}
